#pragma once

#include <QGraphicsWidget>

class Button : public QGraphicsWidget
{
	Q_OBJECT
public:
	Button(const QPixmap &pix, QGraphicsItem *parent = 0)
		: QGraphicsWidget(parent), pixmap(pix)
	{
		setAcceptHoverEvents(true);
	}

	QRectF boundingRect() const
	{
		return QRectF(-65, -65, 65, 65);
	}

	QPainterPath shape() const
	{
		QPainterPath path;
		path.addEllipse(boundingRect());
		return path;
	}

	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *) ;

signals:
	void pressed();

public slots:
	void show();

protected:
	void mousePressEvent(QGraphicsSceneMouseEvent *)
	{
		emit pressed();
		update();
	}

	void mouseReleaseEvent(QGraphicsSceneMouseEvent *)
	{
		update();
	}

private:
	QPixmap pixmap;
};